package com.ruix.app.ui.message;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.ruix.app.R;
import com.ruix.app.adapter.superadapter.IMulItemViewType;
import com.ruix.app.constant.RuiXConstant;
import com.ruix.app.manager.UserManager;
import com.ruix.app.mapper.ActionMapper;
import com.ruix.app.mapper.ClasssDetailMapper;
import com.ruix.app.mapper.PostAutherMapper;
import com.ruix.app.mapper.PostCardMapper;
import com.ruix.app.mapper.PostCommentsMapper;
import com.ruix.app.model.ClassDetail;
import com.ruix.app.model.Classes;
import com.ruix.app.model.Comment;
import com.ruix.app.model.MessageModel;
import com.ruix.app.model.PostAuther;
import com.ruix.app.model.PostsCard;
import com.ruix.app.model.User;
import com.ruix.app.network.RXObserver;
import com.ruix.app.network.RequestFactory;
import com.ruix.app.network.exception.RequestApiException;
import com.ruix.app.ui.adapter.PracticalCommuniAdapter;
import com.ruix.app.ui.base.BaseActivity;
import com.ruix.app.ui.stratum.ClassesStratumActivity;
import com.ruix.app.util.ShareUtil;
import com.ruix.app.util.SoftInputUtil;
import com.ruix.app.widget.CommonTitleBar;
import com.ruix.app.widget.dialog.CommentDialog;
import com.ruix.app.widget.dialog.CopyCommentDialog;
import com.ruix.app.widget.dialog.DeleteCommentDialog;
import com.ruix.app.widget.dialog.DeletePostDialog;
import com.ruix.app.widget.dialog.PostAuthorInfoDialog;
import com.ruix.app.widget.dialog.ReportPostDialog;


import java.util.ArrayList;

import io.reactivex.disposables.Disposable;

/**
 * Created by hadexs on 2017/5/7.
 */

public class MessagePostActivity extends BaseActivity implements View.OnClickListener,PracticalCommuniAdapter.PracticalCommuActionListenler,DeleteCommentDialog.DeleteCommentListener,DeletePostDialog.DeletePostListener {


    public static Intent newInstant(Context context, MessageModel messageModel) {
        Intent intent = new Intent(context, MessagePostActivity.class);
        intent.putExtra("MessageModel", messageModel);
        return intent;
    }

    private MessageModel messageModel;
    private PostsCard postsCard;
    private ClassDetail classDetail;

    private ListView listView;
    private PracticalCommuniAdapter adapter;

    private PopupWindow moreActionPop, commentPop, sharePop;
    private DeleteCommentDialog deleteCommentDialog;
    private PostAuthorInfoDialog authorInfoDialog;
    private CopyCommentDialog copyCommentDialog;
    private DeletePostDialog deletePostDialog;
    private ReportPostDialog reportPostDialog;



    @Override
    protected int loadViewLayout() {
        return R.layout.activity_message_post;
    }

    @Override
    protected void initView() {
        setTitle("消息详情");
        listView = (ListView)findViewById(R.id.lv_posts);
        setAdapter();



        //
    }

    private void setAdapter() {
        adapter = new PracticalCommuniAdapter(this, null, new IMulItemViewType<PostsCard>() {
            @Override
            public int getViewTypeCount() {
                return 7;
            }

            @Override
            public int getItemViewType(int position, PostsCard postsCard) {
                return postsCard.getDisplayType().ordinal();
            }

            @Override
            public int getLayoutId(int viewType) {
                int layout = R.layout.item_posts_style_one;
                switch (viewType) {
                    case 0:
                        layout = R.layout.item_posts_style_one;
                        break;
                    case 1:
                        layout = R.layout.item_posts_style_pic_glide_one;
                        break;
                    case 2:
                        layout = R.layout.item_posts_style_pic_glide_two;
                        break;
                    case 3:
                        layout = R.layout.item_posts_style_pic_glide_three;
                        break;
                    case 4:
                        layout = R.layout.item_posts_style_pic_glide_four;
                        break;
                    case 5:
                        layout = R.layout.item_posts_style_pic_glide_five;
                        break;
                    case 6:
                        layout = R.layout.item_posts_style_pic_glide_seven;
                        break;

                }
                return layout;
            }
        });
        adapter.setActivity(this);

        listView.setAdapter(adapter);
        adapter.setActionListenler(this);
        adapter.setHasMoreAction(false);
//        adapter.setCanShare(true);
//        adapter.setCanDelete(false);

    }





    @Override
    protected void initLocalData() {
        Intent intent = getIntent();
        if (intent != null) {
            messageModel = (MessageModel) intent.getSerializableExtra("MessageModel");
        }

        if (messageModel != null && !TextUtils.isEmpty(messageModel.getFromCname())) {
            CommonTitleBar titleBar = getTitleBar();
            TextView titleBarRightBtn = titleBar.getRightBtn();
            titleBarRightBtn.setText(messageModel.getFromCname());
            titleBarRightBtn.setTextColor(getResources().getColor(R.color.green));
            titleBarRightBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Classes classes = new Classes();
                    classes.setID(messageModel.getFromCid());
                    classes.setName(messageModel.getFromCname());
                    UserManager.sharedInstance().setCurrentClass(classes);
                    Intent intent = ClassesStratumActivity.newIntent(MessagePostActivity.this, classes,null);
                    startActivity(intent);

                }
            });
        }


        loadPostDetail();
        loadClassDetail();
    }

    @Override
    protected void initListener() {

    }

    private void setNavigationBarRightView(){
        //// TODO: 2017/5/7

    }


    @Override
    public void onClick(View v) {


    }


    private void loadPostDetail() {
        if (messageModel == null){
            return;
        }
        showLoading();
        RequestFactory.classPostsDetail(messageModel.getOid(), new PostCardMapper(), new RXObserver<PostsCard>() {
            @Override
            public void onSubscribe(Disposable d) {
                //post
            }

            @Override
            public void onNext(PostsCard value) {
                if (value != null) {
                    postsCard = value;
                    adapter.add(postsCard);
                }
            }

            @Override
            public void onError(Throwable e) {
                dismissLoading();

                if (e instanceof RequestApiException){
                    RequestApiException exception = (RequestApiException)e;
                    if (exception.getErrorCode()  == 10001){
                        showErrorTip(e.getMessage());
                        finish();
                        return;
                    }
                }
                resolveException(e);
            }

            @Override
            public void onComplete() {
                dismissLoading();
            }
        });

    }


    @Override
    public void deletePosts(PostsCard item, int position) {
        showDeletePostDialog(item.getID(), position);
    }

    @Override
    public void sharePosts(PostsCard item) {
        showSharePopupWindow(getRootView(), item);

    }

    @Override
    public void commentPosts(PostsCard item, int position) {
        User user = UserManager.getCurrentUser();
        if (user != null && user.isProhibited()){
            showErrorTip("你已被圈子禁言");
            return;
        }
        showCommentDialog(item,null);
//        showCommentPopupWindow(getRootView(), item, null);
    }

    @Override
    public void moreActionPosts(PostsCard item) {
        showMoreActionPopupWindow(getRootView(), item.getID());
    }

    @Override
    public void praisePosts(PostsCard item, int position) {
        item.addPraise();
        adapter.notifyDataSetHasChanged();
        praisePost(item.getID());

    }

    @Override
    public void unpraisePosts(PostsCard item, int position) {
        item.canclePraise();
        adapter.notifyDataSetHasChanged();
        praisePost(item.getID());
    }

    @Override
    public void actionComment(PostsCard item, int commentPosition) {
        ArrayList<Comment> comments = item.getComments();
        Comment comment = comments.get(commentPosition);
        String uid = UserManager.getCurrentUser().getID();
        if (comment.getAuthorId().equals(uid)) {
            showDeleteCommentDialog(item, commentPosition);
        } else {
//            showCommentDialog(item,comment);
            showCommentDialog(item,comment);
//            showCommentPopupWindow(this.getRootView(), item, comment);
        }

    }

    @Override
    public void onLongClickComment(PostsCard item, int commentPosition) {
        ArrayList<Comment> comments = item.getComments();
        if (comments != null && comments.size() > commentPosition) {
            Comment comment = comments.get(commentPosition);
            String uid = UserManager.getCurrentUser().getID();
            if (comment.getAuthorId().equals(uid)) {
                showDeleteCommentDialog(item, commentPosition);
            } else {
                showCopyCommentDialog(comment.getContent());
            }
        }
    }

    @Override
    public void clickAvatar(PostsCard item, int position) {
        RequestFactory.postAuthorInfo(item.getID(), new PostAutherMapper(), new RXObserver<PostAuther>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(PostAuther value) {
                if (value != null) {
                    showPostAutherInfoDialog(value);
                }
            }

            @Override
            public void onError(Throwable e) {
                resolveException(e);
            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void onLongClickPost(PostsCard item, int commentPosition) {
        String words = item.getWords();
        if (!TextUtils.isEmpty(words)) {
            showCopyCommentDialog(words);
        }
    }

    private void showPostAutherInfoDialog(PostAuther postAuther) {
        if (authorInfoDialog == null) {
            authorInfoDialog = new PostAuthorInfoDialog(this);
        }
        if (!authorInfoDialog.isShowing()) {
            authorInfoDialog.show(postAuther);
            authorInfoDialog.setPostAuther(postAuther);
        }
    }


    //点赞 取消点赞
    private void praisePost(String id) {
        RequestFactory.likePosts(id, null, new RXObserver() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Object value) {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }


    private void showCopyCommentDialog(String comment) {
        if (copyCommentDialog == null) {
            copyCommentDialog = new CopyCommentDialog(this);
        }
        copyCommentDialog.show(comment);
    }

    private void showDeleteCommentDialog(PostsCard item, int commentPosition) {
        if (deleteCommentDialog == null) {
            deleteCommentDialog = new DeleteCommentDialog(this);
            deleteCommentDialog.setListener(this);
        }
        deleteCommentDialog.show(item, commentPosition);
    }

    @Override
    public void deleteCommentPositive(PostsCard item, int commentPosition) {
        deleteComment(item, commentPosition);
    }


    private void deleteComment(final PostsCard item, final int commentPosition) {
        Comment comment = item.getComments().get(commentPosition);
        RequestFactory.deleteCommnet(comment.getID(), new ActionMapper(), new RXObserver<Boolean>() {

            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Boolean value) {
                if (value) {
                    item.deleteComment(commentPosition);
                    adapter.notifyDataSetHasChanged();
                }

            }

            @Override
            public void onError(Throwable e) {
                resolveException(e);
            }

            @Override
            public void onComplete() {

            }
        });
    }

    private void showCommentDialog(final PostsCard item, final Comment comment) {
        CommentDialog dialog =  CommentDialog.newInstance(this,item,comment,new CommentDialog.CommentListener(){

            @Override
            public void submitCommentAction(String commentStr) {
                submitComment(item, comment, commentStr);
            }
        });
        dialog.show();
        dialog.initHint();
    }

    private void showCommentPopupWindow(View view, final PostsCard item, final Comment comment) {
        if (commentPop != null && commentPop.isShowing()){
            commentPop.dismiss();
            commentPop = null;
        }

//        if (commentPop == null) {
            Activity activity = this;
            View contentView = LayoutInflater.from(activity).inflate(
                    R.layout.layout_circle_comment, null);
            final EditText editText = (EditText) contentView.findViewById(R.id.et_leave_words);
            editText.setTextIsSelectable(true);
            if (comment != null) {
                String name = comment.getAuthorName();
                if (!TextUtils.isEmpty(name)) {
                    editText.setHint(String.format("回复：%s", name));
                }
            } else {
                if (!TextUtils.isEmpty(item.getUserName())){
                    editText.setHint(String.format("评论：%s", item.getUserName()));
                }
            }

            final TextView sendComment = (TextView) contentView.findViewById(R.id.tv_send_message);
            editText.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    if (s.length() > 0) {
                        sendComment.setEnabled(true);
                    } else {
                        sendComment.setEnabled(false);
                    }
                }
            });
            sendComment.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String commentStrin = editText.getText().toString();
                    if (!TextUtils.isEmpty(commentStrin)) {
                        dismissCommentPopupWindow();
                        submitComment(item, comment, commentStrin);
                    } else {
                        showErrorTip("评论内容不能为空");
                    }
                }
            });
            commentPop = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            commentPop.setFocusable(true);
            commentPop.setBackgroundDrawable(new BitmapDrawable());
            commentPop.setOutsideTouchable(true);
            commentPop.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
            commentPop.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
            commentPop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
            commentPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                commentPop = null;
            }
        });
            SoftInputUtil.show(this);
//        } else if (commentPop != null && !commentPop.isShowing()) {
//            commentPop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
//            SoftInputUtil.show(this);
//        } else {
//            dismissCommentPopupWindow();
//        }
    }

    private void dismissCommentPopupWindow() {
        if (commentPop != null && commentPop.isShowing()) {
            commentPop.dismiss();
            commentPop = null;
        }
    }


    //评论
    private void submitComment(final PostsCard item, final Comment comment, String commentContent) {
        final Comment newComment = new Comment();
        if (comment != null) {
            newComment.setReplyID(comment.getAuthorId());
        }
        newComment.setContent(commentContent);
        RequestFactory.pushCommnet(item.getID(), newComment, null, new RXObserver() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Object value) {
                showErrorTip("提交成功");
                loadPostsComment(item);
                //
            }

            @Override
            public void onError(Throwable e) {
                resolveException(e);
            }

            @Override
            public void onComplete() {

            }
        });
    }

    //获取评论
    private void loadPostsComment(final PostsCard item) {
        RequestFactory.classPostsDetail(item.getID(), new PostCommentsMapper(), new RXObserver<ArrayList<Comment>>() {
            @Override
            public void onSubscribe(Disposable d) {
                //post
            }

            @Override
            public void onNext(ArrayList<Comment> value) {
                item.repaceComments(value);
                adapter.notifyDataSetHasChanged();
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }




    public void showMoreActionPopupWindow(View view, final String postId) {
        if (moreActionPop == null) {
            Activity activity = this;
            View contentView = LayoutInflater.from(activity).inflate(
                    R.layout.layout_posts_more, null);
            contentView.findViewById(R.id.btn_enjoy_pay).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissMoreActionPopupWindow();
                    showErrorTip("打赏功能即将上线");
                }
            });

            contentView.findViewById(R.id.btn_accuse_posts).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    reportPosts(postId);
                    showReportPostComfirmDialog(postId);
                    dismissMoreActionPopupWindow();
                }
            });

            moreActionPop = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT,
                    (int) this.getResources().getDimension(R.dimen.h_w_96));
            WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
            lp.alpha = 0.6f;
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
            activity.getWindow().setAttributes(lp);
            moreActionPop.setAnimationStyle(R.style.PopupWindowAnimation2);
            moreActionPop.setFocusable(true);
            moreActionPop.setBackgroundDrawable(new BitmapDrawable());
            moreActionPop.setOutsideTouchable(true);
            moreActionPop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
            moreActionPop.setOnDismissListener(new PopupWindow.OnDismissListener() {

                // 在dismiss中恢复透明度
                public void onDismiss() {
                    Activity activity = MessagePostActivity.this;
                    WindowManager.LayoutParams lp = activity.getWindow()
                            .getAttributes();
                    lp.alpha = 1f;
                    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                    activity.getWindow().setAttributes(lp);
                }
            });
        } else if (moreActionPop != null && !moreActionPop.isShowing()) {
            Activity activity = MessagePostActivity.this;
            WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
            lp.alpha = 0.6f;
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
            activity.getWindow().setAttributes(lp);
            moreActionPop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
        }
    }

    public void dismissMoreActionPopupWindow() {
        if (moreActionPop != null && moreActionPop.isShowing()) {
            moreActionPop.dismiss();
        }
    }


    private void showReportPostComfirmDialog(String postId) {
        if (reportPostDialog == null) {
            reportPostDialog = new ReportPostDialog(this);
            reportPostDialog.setListener(new ReportPostDialog.ReportPostListener() {
                @Override
                public void reportPostPositive(String postID) {
                    reportPosts(postID);
                }
            });
        }
        reportPostDialog.show(postId);
    }



    private void reportPosts(String postId) {
        showLoading();
        RequestFactory.reportPost(postId, null, new RXObserver() {
            @Override
            public void onSubscribe(Disposable d) {
            }

            @Override
            public void onNext(Object value) {
                showErrorTip("举报成功");
            }

            @Override
            public void onError(Throwable e) {
                dismissLoading();
                resolveException(e);
                
            }

            @Override
            public void onComplete() {
                dismissLoading();
            }
        });

    }

    private void showDeletePostDialog(String id, int position) {
        if (deletePostDialog == null) {
            deletePostDialog = new DeletePostDialog(this);
            deletePostDialog.setListener(this);
        }
        deletePostDialog.show(id, position);
    }

    @Override
    public void deletePostPositive(String postID, int commentPosition) {
        deletePost(postID, commentPosition);
    }

    //删除帖子
    private void deletePost(String postId, final int position) {

        RequestFactory.deletePosts(postId, new ActionMapper(), new RXObserver<Boolean>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Boolean value) {
                if (value) {
                    adapter.remove(position);
                    finish();
                    //todo  通知更新列表
                }
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });

    }


    public void showSharePopupWindow(View view, final PostsCard item) {
        if (sharePop != null && sharePop.isShowing()) {
            sharePop.dismiss();
            sharePop = null;
        }
//        if (sharePop == null) {
            Activity activity = this;
            View contentView = LayoutInflater.from(activity).inflate(
                    R.layout.dialog_share_post, null);
            contentView.findViewById(R.id.ll_share_to_wechat).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissSharePopupWindow();
                    shareShit(item, true);
                }
            });

            contentView.findViewById(R.id.ll_share_to_circle).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissSharePopupWindow();
                    shareShit(item, false);
                }
            });

            sharePop = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT,
                    (int) this.getResources().getDimension(R.dimen.h_w_96));
            WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
            lp.alpha = 0.6f;
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
            activity.getWindow().setAttributes(lp);
            sharePop.setAnimationStyle(R.style.PopupWindowAnimation2);
            sharePop.setFocusable(true);
            sharePop.setBackgroundDrawable(new BitmapDrawable());
            sharePop.setOutsideTouchable(true);
            sharePop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
            sharePop.setOnDismissListener(new PopupWindow.OnDismissListener() {

                // 在dismiss中恢复透明度
                public void onDismiss() {
                    Activity activity = MessagePostActivity.this;
                    WindowManager.LayoutParams lp = activity.getWindow()
                            .getAttributes();
                    lp.alpha = 1f;
                    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                    activity.getWindow().setAttributes(lp);
                    sharePop = null;
                }
            });
//        } else if (sharePop != null && !sharePop.isShowing()) {
//            // TODO: 2017/4/26
//            Activity activity = MessagePostActivity.this;
//            WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
//            lp.alpha = 0.6f;
//            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//            activity.getWindow().setAttributes(lp);
//            sharePop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
//        }
    }

    public void dismissSharePopupWindow() {
        if (sharePop != null && sharePop.isShowing()) {
            sharePop.dismiss();
            sharePop = null;
        }
    }

    private void shareShit(PostsCard postsCard, boolean firend) {
        String title = postsCard.getWords();
        String content = String.format("%s的主题", postsCard.getUserName());
        String webUrl = RuiXConstant.WX_SHARE_URL + postsCard.getEncryptId();
        String thumbUrl = null;
        if (classDetail != null) {
             thumbUrl = classDetail.getIcon();
        }


        if (title == null) {
            content = "";
        }
        if (content == null) {
            content = "";
        }
        if (TextUtils.isEmpty(thumbUrl)){
            thumbUrl = postsCard.getAvatarUrl();
        }

        if (firend) {
            // TODO: 2017/5/22
            ShareUtil.shareToTimeline(this, thumbUrl, webUrl, title, content, null);
        } else {
            ShareUtil.shareToSession(this, thumbUrl, webUrl, title, content, null);
        }
    }



    private void loadClassDetail(){
        if (messageModel == null || TextUtils.isEmpty(messageModel.getFromCid())){
            return;
        }
        RequestFactory.classDetail(messageModel.getFromCid(), new ClasssDetailMapper(messageModel.getFromCid()), new RXObserver<ClassDetail>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(ClassDetail value) {
                if (value != null) {
                    classDetail = value;
                    if (classDetail != null) {
                        adapter.setProhibited(classDetail.isProhibited());//
                        adapter.setCanShare(classDetail.isCanSharePost());
                        adapter.setFriendCircle(classDetail.isTeacherFriendCircle());
                        adapter.notifyDataSetHasChanged();
                    }
                }
            }

            @Override
            public void onError(Throwable e) {
                resolveException(e);
            }

            @Override
            public void onComplete() {

            }
        });

    }
}
